package api

import (
	"application/basic/config"
	"application/handler/request"
	__ "application/proto"
	"context"
	"github.com/gin-gonic/gin"
	"log"
	"net/http"
	"time"
)

func List(c *gin.Context) {
	var req request.VideoListReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(http.StatusOK, gin.H{
			"code": 10000,
			"msg":  "验证失败",
			"date": err.Error(),
		})
		return
	}
	_, cancel := context.WithTimeout(context.Background(), time.Second)
	defer cancel()
	r, err := config.ApiClient.List(c, &__.VideoListReq{
		Page:     int32(req.Page),
		PageSize: int32(req.PageSize),
	})
	if err != nil {
		log.Fatalf("could not greet: %v", err)
	}
	c.JSON(http.StatusOK, gin.H{
		"code": 200,
		"msg":  "展示成功",
		"date": r.List,
	})
}
